﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using mshtml;
namespace Paros.Win
{
    public partial class SimpleEditorForm : DockContent
    {
        public SimpleEditorForm()
        {
            InitializeComponent();
            editor.DocumentText = "<html><body></body></html>";
            IHTMLDocument2 doc =
                editor.Document.DomDocument as IHTMLDocument2;
  
            doc.designMode = "On";
        }

        public string HTMLBody
        { 
            get { 
                return this.editor.Document.Body.InnerHtml; 
            } 
            set {
                if (editor.Document.Body == null)
                    editor.Document.Write(value);
                else
                    editor.Document.Body.InnerHtml = value;
            } 
        
        }

        private void editor_TextChanged(object sender, EventArgs e)
        {
            ((mainForm)this.TopLevelControl).OnDocumentChanged();
        }

        private void editor_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 83 )
            {
                ((mainForm)this.TopLevelControl).OnDocumentSaving();
            }
        }
    }
}
